#ifndef __APP_MAC_H__
#define __APP_MAC_H__

#include "Commissioning.h"
#include "LoRaMac.h"
#include "utilities.h"
#include <stdio.h>

#ifndef ACTIVE_REGION
#    warning "No active region defined, LORAMAC_REGION_CN470 will be used as default."
#    define ACTIVE_REGION LORAMAC_REGION_CN470
#endif

/*!
 * Device states
 */
typedef enum eDeviceState {
    DEVICE_STATE_IDLE,
    DEVICE_STATE_INIT,        // 设备初始化
    DEVICE_STATE_JOIN,        // 设备注册
    DEVICE_STATE_LINKCHECK,   // 设备进行LinkCheck
    DEVICE_STATE_TIME_CHECK,  // 设备进行DeviceTime 对时
    DEVICE_STATE_SEND,        // 设备发送
    DEVICE_STATE_CYCLE,       // 设备循环
    DEVICE_STATE_SLEEP,       // 设备休眠
} DEVICE_STATE_T;

extern DEVICE_STATE_T DeviceState;

void AppMacInit(LoRaMacPrimitives_t* LoRaMacPrimitives, LoRaMacCallback_t* LoRaMacCallbacks);
bool AppMacJoin(void);
bool AppMacLinkCheck(void);
bool AppMacDeviceTimeCheck(void);
void AppMacSendData(void);
bool AppMacStateCheck();
bool SendAppData(void* fBuffer, uint16_t appSize);
#endif
